$(function () {
    function tt() {
        $.ajax({
            type: "POST",
            url: "LogOnQrCode",
            contentType: "application/json; charset=utf-8",
            success: function (n) {
                $("#qrcode").kendoQRCode({value: n.QrCode, size: 200});
                r = setInterval(yt, 1e3, n.LogOnTicket)
            }
        })
    }

    function yt(u) {
        $.ajax({
            type: "POST",
            url: "Account/LogOnByQrCode",
            data: JSON.stringify({ticket: u, deviceCode: e()}),
            contentType: "application/json; charset=utf-8",
            success: function (u) {
                if (n = u, u.State == t.Success) clearInterval(r), Ares.logOn(n); else if (u.State == t.QrCodeExpired) clearInterval(r), $("#qrcode").hide(), $("#refresh-qrcode-div").show(), $("#qrcode-error").html("二维码失效"); else if (u.State == t.ProviderLeft) clearInterval(r), $("#qrcode").hide(), $("#refresh-qrcode-div").show(), $("#qrcode-error").html(i.providerLeft); else {
                    if (u.State == t.NeedExtraValidate) {
                        clearInterval(r);
                        b();
                        $("#message-title").html("扫码成功，请输入短信验证码");
                        $("#account").val(n.User.Account);
                        $("#validationMobile").val(n.ValidationMobile);
                        $("#isShowMobileValidation").val(!0);
                        return
                    }
                    if (u.State == t.IpNotAllowed) clearInterval(r), $("#qrcode").hide(), $("#refresh-qrcode-div").show(), $("#qrcode-error").html(i.ipNotAllowed); else if (isDeviceMgmtEnabled && (u.State == t.UnknownDevice || u.State == t.InvalidDevice)) {
                        Ares.getDeviceCode(!0) && o();
                        return
                    }
                }
            }
        })
    }

    function pt() {
        $("#sendSmsBtn").attr("disabled", "true");
        l = setInterval(function () {
            u = u - 1;
            $("#sendSmsBtn").attr("disabled", "true");
            $("#sendSmsBtn").text("重新获取(" + u + ")");
            u == 0 && (clearTimeout(l), u = 60, $("#sendSmsBtn").removeAttr("disabled"), $("#sendSmsBtn").text("获取短信验证码"))
        }, 1e3)
    }

    var n = {}, c = null, r = null, l = null, f = !1, a = null, p = null, v = null, e = function () {
        return isDeviceMgmtEnabled ? Ares.getDeviceCode() : ""
    }, it, u, rt;
    jQuery.fn.center = function (n, t) {
        return this.parent().css("position", "relative"), this.css("position", "absolute"), this.css("top", "50%"), this.css("left", "50%"), this.css("margin-left", "-" + (n || $(this).outerWidth()) / 2 + "px"), this.css("margin-top", "-" + (t || $(this).outerHeight()) / 2 + "px"), this
    };
    jQuery.fn.centerScreen = function (n, t) {
        return this.css("position", "fixed"), this.css("top", "50%"), this.css("left", "50%"), this.css("margin-left", "-" + (n || $(this).outerWidth()) / 2 + "px"), this.css("margin-top", "-" + (t || $(this).outerHeight()) / 2 + "px"), this
    };
    var ut = function (n, t) {
        localStorage && n && (localStorage.setItem("lastLoginOffice", n), localStorage.setItem("lastLoginOfficeName", t))
    }, w = function (n) {
        var t = $('<div style="position: absolute;top:0;bottom:0;width:100%;height:100%;z-index:99"><\/div>'),
            i = $('<img src="/app-resource/images/busy-indicator.gif" alt="" />');
        return i.css({
            width: "48px",
            height: "48px",
            "z-index": 100,
            position: "relative",
            top: "calc(50% - 24px)",
            left: "calc(50% - 24px)"
        }), t.append(i), n.append(t), n.css({position: "relative"}), t.click(function (n) {
            n.stopPropagation()
        }), t
    }, ft = function () {
        $("#validationCodeContainer").show()
    }, b = function () {
        clearTimeout(l);
        $("#mobile-code-login-form").show();
        $("#mobile-login-form").hide();
        $("#login-by-mobile").hide();
        $("#login-by-computer").hide();
        $("#login-form").hide()
    }, o = function () {
        window.location = applyDeviceUrl + "?dq=" + e()
    }, s = function (n) {
        n || (n = $("#validationCodeImg")[0]);
        n.src = "/ValidationCode?time=" + (new Date).getTime()
    }, et = function () {
        var n, t, i, r;
        localStorage && (n = localStorage.getItem("lastLoginOffice"), n) && (a = n, t = localStorage.getItem("lastLoginOfficeName"), i = $("#last-login-office-text"), i.show(), t ? (r = localStorage.getItem("lastLoginOfficeInstitutionCode"), r && (t = t + "(" + r + ")"), i.find("#office-name-text").text(t).val(n)) : $.get("/GetOfficeName?officeId=" + n, function (t) {
            t ? (ut(n, t), i.find("#office-name-text").text(t).val(n)) : localStorage.removeItem("lastLoginOffice")
        }))
    }, ot = function () {
        var t, n;
        localStorage && (t = localStorage.getItem("lastLoginOffice"), offices.length != 1 && t) && (n = $("#login-select-other-office"), n.show(), n.click(function () {
            f = !0;
            a = null;
            y(!1)
        }))
    }, k = function (n, t) {
        if (!t) {
            $("#login-form,#login-by-mobile,#login-by-computer,#mobile-login-form,#mobile-code-login-form").hide();
            var r = localStorage.getItem("lastLoginOfficeName"),
                f = localStorage.getItem("lastLoginOfficeInstitutionCode"),
                u = n.LoginOffices ? n.LoginOffices.map(function (n) {
                    return n.Id
                }) : null, e = u ? {officeIds: u} : null, i = $("#login-select-office-view")
        }
        $.post("/Account/GetOfficesGroup", e, function (e) {
            if (t) {
                e && e[0] && e[0].InstitutionCode ? localStorage.setItem("lastLoginOfficeInstitutionCode", e[0].InstitutionCode) : localStorage.removeItem("lastLoginOfficeInstitutionCode");
                return
            }
            if (i.show(), i.find("#header-login-user-name").text(n.Provider.Name), r) {
                var o = i.find("#last-login-office-name");
                f && (r = r + "(" + f + ")");
                o.text(r).attr("title", r)
            } else i.find("#last-login-office-title").hide();
            i.find("#switch-office-search-input").on("input", function () {
                clearTimeout(p);
                p = setTimeout(function () {
                    var t = $("#switch-office-search-input").val(), i = st(e, t);
                    g(i, n.IsRoot ? null : u)
                }, 800)
            });
            g(e, n.IsRoot ? null : u);
            i.find("#switch-login-office-list").on("click", ".switch-office-btn", function () {
                var t = $(this), i = t.attr("office-id"), r = t.attr("institution-code");
                ht(i, n, r || null)
            })
        })
    }, st = function (n, t) {
        var r = t, e = n;
        if (!r) return $.extend(!0, [], n);
        var f = function (n) {
            var i = n.Name.toLowerCase(), t;
            return n.Items && n.Items.length !== 0 ? (t = [], n.Items.forEach(function (n) {
                f(n) && t.push(n.OfficeId)
            }), n.Items = n.Items.filter(function (n) {
                return t.every(function (t) {
                    return n.OfficeId != t
                })
            }), i.indexOf(r.toLowerCase()) < 0 && (!n.Items || n.Items.length === 0) ? n : null) : i.indexOf(r.toLowerCase()) < 0 ? n : null
        }, i = $.extend(!0, [], e), u = [];
        return i.forEach(function (n) {
            f(n) && u.push(n.OfficeId)
        }), u.length > 0 && (i = i.filter(function (n) {
            return u.every(function (t) {
                return n.OfficeId != t
            })
        })), i
    }, d = function (n) {
        return n.forEach(function (n) {
            n.BizType == 1 ? n.image = "/content/imgs/icon-office-zhiying.png" : n.BizType == 0 && (n.image = "/content/imgs/icon-office-jiameng.png");
            n.Items && n.Items.length > 0 ? d(n.Items) : n.Items = null
        }), offices
    }, g = function (n, t) {
        var r = $("#switch-login-office-list"), i;
        d(n);
        i = new kendo.data.HierarchicalDataSource({
            data: n,
            schema: {
                model: {
                    children: {
                        schema: {
                            data: "Items",
                            model: {children: {schema: {data: "Items", model: {children: "Items"}}}}
                        }
                    }
                }
            }
        });
        v ? v.setDataSource(i) : v = r.kendoTreeView({
            template: function (n) {
                var i = n.item, r = '<img class="k-image" alt="" src="' + i.image + '"/>';
                return r += '<span class="switch-span-title" title="' + i.Name + '" >(' + i.Abbr + ")" + i.Name + "<\/span>", (!t || t && t.some(function (n) {
                    return n == i.OfficeId
                })) && (r += '<button office-id="' + i.OfficeId + '" institution-code="' + (i.InstitutionCode || "") + '" class="switch-office-btn">进入<\/button>'), r
            }, dataSource: i
        }).data("kendoTreeView")
    }, wt = function (n, t) {
        var u = [], f = function (n, i) {
            n.forEach(function (n) {
                var r = n.Items, o = r.filter(function (n) {
                    return n.Items.length === 0
                }).map(function (n) {
                    var r = t && t.length > 0 ? t.some(function (t) {
                        return t == n.OfficeId
                    }) : !0;
                    return {name: n.Name, id: n.OfficeId, index: i, canLogin: r}
                }), s = t && t.length > 0 ? t.some(function (t) {
                    return t == n.OfficeId
                }) : !0, h = {name: n.Name, id: n.OfficeId, index: i, canLogin: s, items: o}, e;
                u.push(h);
                e = r.filter(function (n) {
                    return n.Items.length > 0
                });
                f(e, i + 1)
            })
        }, i, r;
        f(n, 0);
        i = $("#switch-login-office-list");
        i.empty();
        r = "";
        u.forEach(function (n) {
            var i = "<tr>", u = n.index * 8 + "px", f = n.canLogin ? "" : "select-disabled", t;
            i += '<td><span class="select-office-block select-group-office ' + f + '" style="margin-left:' + u + '" title="' + n.name + '" office-id="' + n.id + '" >' + n.name + "<\/span><\/td>";
            t = "<td>";
            n.items.forEach(function (n) {
                var i = n.canLogin ? "" : "select-disabled";
                t += '<span class="select-office-block select-item-office ' + i + '" title="' + n.name + '"office-id="' + n.id + '"  >' + n.name + "<\/span>"
            });
            t += "<\/td>";
            i += t;
            r += i + "<\/tr>"
        });
        i.append('<table class="select-table">' + r + "<\/table>")
    }, ht = function (r, u, f) {
        var h = $("#login-select-office-view"), s = w(h);
        $.ajax({
            type: "POST",
            url: window.location.origin + "/SwitchOffice",
            contentType: "application/x-www-form-urlencoded;charset=utf-8",
            data: "account=" + u.Account + "&officeId=" + r + "&deviceCode=" + e() + "&platform=1",
            success: function (r) {
                n = r;
                n.State == t.Success && (localStorage.setItem("lastLoginOfficeInstitutionCode", f || ""), Ares.logOn(n));
                n.State == t.IpNotAllowed && (s.remove(), alert(i.ipNotAllowed));
                isDeviceMgmtEnabled && (r.State == t.UnknownDevice || r.State == t.InvalidDevice) && (s.remove(), $.ajax({
                    type: "POST",
                    url: "/LogOff",
                    contentType: "application/x-www-form-urlencoded;charset=utf-8",
                    data: "platform=1&clientId=" + Ares.getClientId(),
                    complete: function () {
                        Ares.getDeviceCode(!0) && o()
                    }
                }))
            }
        })
    }, t = {
        UnKnown: -1,
        Error: -2,
        Success: 0,
        EmptyAccount: 1,
        EmptyPassword: 2,
        AccountNotExist: 3,
        WrongAccountOrPassword: 4,
        Inactive: 5,
        Expired: 6,
        ProviderNotExist: 7,
        OfficeNotAllowed: 8,
        ProviderInactive: 11,
        ProviderLeft: 12,
        TrialExpired: 13,
        AlreadyLogIn: 14,
        RequireValidationCode: 15,
        WrongValidationCode: 16,
        PersonAccount: 17,
        ExpiredMobileValidationCode: 29,
        WrongMobileValidationCode: 30,
        EmptyMobileValidationCode: 31,
        QrCodeExpired: 34,
        NeedExtraValidate: 37,
        ExtraValidationExpired: 38,
        UnknownDevice: 39,
        InvalidDevice: 40,
        IpNotAllowed: 41,
        AccountLocked: 44,
        AccountFrozen: 47
    }, i = {
        accountNotExists: "用户名或密码错误",
        wrongAccountOrPassword: "用户名或密码错误",
        inactiveAccount: "用户已被删除",
        expiredAccount: "该用户不在有效期内",
        unknownError: "登录出错，请重试",
        accountRequired: "请输入用户名",
        passwordRequired: "请输入密码",
        account4Pwd: {required: "请输入用户名", accountNotExists: "用户名不合法，请重新输入"},
        providerNotExist: "该用户不是诊所员工",
        providerInactive: "该员工已被删除",
        providerLeft: "该员工已经离职",
        officeNotAllowed: "没有权限登录该诊所，请选择登入其他诊所",
        ipNotAllowed: "因IP限制，您无权登录该诊所",
        trialExpired: "您的试用期限已到,请联系领健客服",
        requireValidationCode: "请输入验证码",
        wrongValidationCode: "验证码错误",
        personAccount: "用户名不存在",
        expiredMobileValidationCode: "验证码已过期",
        wrongMobileValidationCode: "验证码错误",
        emptyMobileValidationCode: "输入验证码",
        extraValidationExpiredCode: "当前登录已超时，请重新登录",
        invalidDevice: "无效设备号，请刷新页面后重试"
    }, h = function () {
        return c || (c = $("#login-form")), c
    }, bt = function (n) {
        var r = window.location.search, u, i, t;
        if (r && r.length > 0) for (u = r.substr(1).split("&"), i = 0; i < u.length; i++) if (t = u[i].split("="), t && t.length > 1 && t[0] === n) return decodeURIComponent(t[1]);
        return ""
    }, ct = function (r, u, h, c, l, a) {
        var d = e(), g = $("#isShowMobileValidation").val(), nt = $("#mobileValidationCode").val(),
            tt = Ares.getClientId(), v = $("#login-button"), p;
        v.attr("disabled", !0);
        var it = w(v.parents("form:eq(0)")), rt = !1, y = c;
        c == -1 && (y = $($("#office").children()[0]).val(), rt = !0);
        p = {
            account: r,
            password: u,
            validationCode: h,
            officeId: y,
            platform: 1,
            kickOther: l,
            clientId: tt,
            isCheckMobileValidation: g,
            mobileValidationCode: nt,
            deviceCode: d,
            goToSelectOfficeView: f
        };
        $.ajax({
            type: "POST",
            url: "LogOn",
            data: JSON.stringify(p),
            contentType: "application/json; charset=utf-8",
            success: function (e) {
                var h, c, l;
                if (n = e, h = n.User ? n.User.LoginOffices : null, e.State == t.Success) localStorage.setItem("aresNotificationSoundCheckBypass", "1"), localStorage.setItem("loginSuccessInit", "1"), c = n.ExternalToken || localStorage.getItem("ExternalToken"), c && localStorage.setItem("ExternalToken", c), l = $.fn.passwordStrength(!1, u, r), localStorage.setItem("accountPasswordStrength", l.strength), f && (!h || h.length > 1) ? k(n.User) : (k(n.User, !0), Ares.logOn(n)); else {
                    if (e.State == t.EmptyMobileValidationCode) {
                        $("#mobileValidationError").text(i.emptyMobileValidationCode);
                        return
                    }
                    if (e.State == t.WrongMobileValidationCode) {
                        $("#mobileValidationError").text(i.wrongMobileValidationCode);
                        return
                    }
                    if (e.State == t.ExpiredMobileValidationCode) {
                        $("#mobileValidationError").text(i.expiredMobileValidationCode);
                        return
                    }
                    if (e.State == t.NeedExtraValidate) {
                        b();
                        $("#message-title").html("用户名密码验证成功，请输入短信验证码");
                        $("#validationMobile").val(n.ValidationMobile);
                        $("#isShowMobileValidation").val(!0);
                        return
                    }
                    if (e.State == t.IpNotAllowed) {
                        alert(i.ipNotAllowed);
                        return
                    }
                    isDeviceMgmtEnabled && (e.State == t.UnknownDevice || e.State == t.InvalidDevice) ? Ares.getDeviceCode(!0) && o() : (v.removeAttr("disabled"), n.NeedValidationCode && (ft(), s()), a())
                }
            },
            error: function () {
                n = {State: t.UnKnown};
                a()
            },
            complete: function () {
                it.remove();
                v.attr("disabled", !1)
            }
        })
    }, y = function (i) {
        var r;
        if (i = i || !1, vt(), r = h(), !r.valid()) {
            nt.focusInvalid();
            return
        }
        f || localStorage && localStorage.getItem("lastLoginOffice") || (f = !0);
        var e = $("#account").val(), o = $("#password").val(), s = $("#validationCode").val(), u = a;
        ct(e, o, s, u, i, function () {
            var i, f;
            $("#office").val(u);
            r.valid() || nt.focusInvalid();
            n.State == t.AlreadyLogIn && (i = r.find("#loginPanel"), i.hide(), f = r.find("#confirmPanel"), f.show());
            setTimeout(function () {
                n = {}
            }, 100)
        })
    };
    $.validator.addMethod("accountNotExists", function () {
        return n.State !== t.AccountNotExist
    }, i.accountNotExists);
    $.validator.addMethod("wrongAccountOrPassword", function () {
        return n.State !== t.WrongAccountOrPassword
    }, i.wrongAccountOrPassword);
    $.validator.addMethod("accountLocked", function () {
        return n && n.Message && ($.validator.messages.accountLocked = n.Message), n.State !== t.AccountLocked
    }, $.validator.messages.accountLocked);
    $.validator.addMethod("accountFrozen", function () {
        return n && n.Message && ($.validator.messages.accountFrozen = n.Message), n.State !== t.AccountFrozen
    }, $.validator.messages.accountFrozen);
    $.validator.addMethod("inactiveAccount", function () {
        return n.State !== t.Inactive
    }, i.inactiveAccount);
    $.validator.addMethod("expiredAccount", function () {
        return n.State !== t.Expired
    }, i.expiredAccount);
    $.validator.addMethod("providerNotExist", function () {
        return n.State !== t.ProviderNotExist
    }, i.providerNotExist);
    $.validator.addMethod("providerInactive", function () {
        return n.State !== t.ProviderInactive
    }, i.providerInactive);
    $.validator.addMethod("providerLeft", function () {
        return n.State !== t.ProviderLeft
    }, i.providerLeft);
    $.validator.addMethod("officeNotAllowed", function () {
        return n.State !== t.OfficeNotAllowed
    }, i.officeNotAllowed);
    $.validator.addMethod("unknownError", function () {
        return n.State !== t.UnKnown || n.State !== t.Error
    }, i.unknownError);
    $.validator.addMethod("trialExpired", function () {
        return n.State !== t.TrialExpired
    }, i.trialExpired);
    $.validator.addMethod("personAccount", function () {
        return n.State !== t.PersonAccount
    }, i.personAccount);
    $.validator.addMethod("requireValidationCode", function () {
        var i = n.State !== t.RequireValidationCode;
        return i || s(), i
    }, i.requireValidationCode);
    $.validator.addMethod("wrongValidationCode", function () {
        var i = n.State !== t.WrongValidationCode;
        return i || s(), i
    }, i.wrongValidationCode);
    var nt = h().validate({
        ignore: ".ignore, :hidden:not(.not-ignore)",
        errorClass: "has-error",
        rules: {
            account: {
                required: !0,
                inactiveAccount: !0,
                expiredAccount: !0,
                providerNotExist: !0,
                providerInactive: !0,
                providerLeft: !0,
                trialExpired: !0,
                personAccount: !0
            },
            password: {
                required: !0,
                accountNotExists: !0,
                wrongAccountOrPassword: !0,
                unknownError: !0,
                accountLocked: !0,
                accountFrozen: !0
            },
            validationCode: {requireValidationCode: !0, wrongValidationCode: !0},
            office: "officeNotAllowed"
        },
        messages: {account: {required: "请输入用户名"}, password: {required: "请输入密码"}},
        errorPlacement: function (n, t) {
            lt(n, t)
        },
        success: function (n, t) {
            at(n, t)
        }
    }), lt = function (n, t) {
        t.hasClass("has-error") && (t.parent().addClass("has-error"), n.insertAfter(t.parent()), n.addClass("label"), n.addClass("label-danger"))
    }, at = function (n, t) {
        var i = $(t).closest(".form-group");
        i.find(".has-error").removeClass("has-error");
        i.find(".label-danger").remove()
    }, vt = function () {
        var t = h(), n = t.validate();
        n && (n.resetForm(), n.reset(), t.find(".has-error").removeClass("has-error"))
    };
    $("#refresh-qrcode-btn").on("click", function () {
        $("#qrcode").html("");
        $("#qrcode").show();
        $("#refresh-qrcode-div").hide();
        tt()
    });
    $("#login-by-mobile").on("click", function () {
        $("#login-by-mobile").hide();
        $("#login-by-computer").show();
        $("#login-form").hide();
        $("#mobile-login-form").show();
        $("#qrcode").html("");
        $("#qrcode").show();
        $("#refresh-qrcode-div").hide();
        $("#mobile-code-login-form").hide();
        $("#validationMobile").val("");
        $("#message-info").html("");
        $("#mobileValidationCode").val("");
        $("#mobileValidationError").text("");
        tt()
    });
    $("#mobile-login-button").on("click", function () {
        var u = $("#mobileValidationCode").val();
        $.ajax({
            type: "POST",
            url: "Account/LogOnByMobileCode",
            data: JSON.stringify({mobileCode: u, deviceCode: e()}),
            contentType: "application/json; charset=utf-8",
            success: function (u) {
                if (n = u, u.State == t.Success) clearInterval(r), Ares.logOn(n); else {
                    if (u.State == t.EmptyMobileValidationCode) {
                        $("#mobileValidationError").text(i.emptyMobileValidationCode);
                        return
                    }
                    if (u.State == t.WrongMobileValidationCode) {
                        $("#mobileValidationError").text(i.wrongMobileValidationCode);
                        return
                    }
                    if (u.State == t.ExpiredMobileValidationCode) {
                        $("#mobileValidationError").text(i.expiredMobileValidationCode);
                        return
                    }
                    if (u.State == t.ExtraValidationExpired) {
                        $("#mobileValidationError").text(i.extraValidationExpiredCode);
                        return
                    }
                    if (isDeviceMgmtEnabled && (u.State == t.UnknownDevice || u.State == t.InvalidDevice)) {
                        Ares.getDeviceCode(!0) && o();
                        return
                    }
                }
            }
        })
    });
    $("#return-password-login").on("click", function () {
        clearInterval(r);
        location.reload()
    });
    $("#return-computer-login").on("click", function () {
        $("#login-by-mobile").show();
        $("#login-by-computer").hide();
        $("#login-form").show();
        $("#mobile-login-form").hide();
        $("#mobile-code-login-form").hide();
        $("#refresh-qrcode-div").hide();
        $("#qrcode").html("");
        $("#qrcode").show();
        clearInterval(r);
        n = {}
    });
    $("#login-by-computer").on("click", function () {
        $("#login-by-mobile").show();
        $("#login-by-computer").hide();
        $("#login-form").show();
        $("#mobile-login-form").hide();
        $("#mobile-code-login-form").hide();
        $("#refresh-qrcode-div").hide();
        $("#qrcode").html("");
        $("#qrcode").show();
        $("#validationMobile").val("");
        $("#message-info").html("");
        $("#mobileValidationCode").val("");
        $("#mobileValidationError").text("");
        clearInterval(r);
        n = {}
    });
    $(document.body).keydown(function (n) {
        var t, i;
        n.which === 13 && (n.preventDefault(), $("#login-form").is(":visible") ? (t = $("#login-button"), t.click()) : $("#mobile-code-login-form").is(":visible") && (i = $("#mobile-login-button"), i.click()))
    });
    it = function (n) {
        var i = n, r, u;
        if (n && n.length > 3) {
            var o = n.substr(0, 3), f = "", t = n.substr(3), e = t;
            for (t.length > 4 && (r = t.length - 4, e = t.substr(0, r), f = t.substr(r)), i = o, u = 0; u < e.length; u++) i += "*";
            i += f
        }
        return i
    };
    u = 61;
    $("#sendSmsBtn").bind("click", function () {
        var t = $("#validationMobile").val(), i = t.replace("+", "%2B"), r = $("#account").val();
        pt();
        $.ajax({
            type: "POST",
            url: "/Account/MobileCode",
            contentType: "application/x-www-form-urlencoded;charset=utf-8",
            data: "mobile=" + i + "&account=" + r + "&officeId=" + n.LoginOfficeId + "&tenantId=" + n.TenantId + "&userID=" + n.User.Id,
            success: function (n) {
                n ? alert(n + "!") : alert("发送成功!");
                $("#message-info").html("短信验证码已发送至：" + it(t))
            }
        })
    });
    rt = function () {
        $("#account").focus();
        $("#validationCodeImg").bind("click", function () {
            s(this)
        });
        $("#login-button").on("click", function (n) {
            n.preventDefault();
            n.stopPropagation();
            y(!1)
        });
        $("#btnCancel").on("click", function () {
            var n = h();
            n.find("#confirmPanel").hide();
            n.find("#loginPanel").show()
        });
        $("#btnConfirm").on("click", function () {
            y(!0)
        });
        et();
        ot()
    };
    rt()
}), function (n) {
    Ares = n.Ares || {};
    Ares.logOffUrl = "/logoff?platform=1";
    Ares.getClientId = function () {
        return $.cookie("ClientId") || null
    };
    Ares.initLogOffUrl = function () {
        var t = Ares.getClientId(), n = "/logoff?platform=1&clientId=" + t;
        Ares.logOffUrl = n;
        Ares.logOffUrlAjax = n + "&signOut=false"
    };
    Ares.disableAutoLogOff = function () {
        Ares.autoLogOffDisabled = !0
    };
    Ares.logOn = function (t) {
        var r = JSON.stringify(t), u, f, i;
        n.localStorage ? (n.localStorage.setItem("LogOnResult", r), t.User && (n.localStorage.setItem("lastLoginOffice", t.LoginOfficeId), n.localStorage.setItem("lastLoginOfficeName", t.OfficeName), u = btoa(btoa("LastLoginTime")), f = btoa(btoa((new Date).getTime())), localStorage.setItem(u, f))) : $.cookie("LogOnResult", r);
        t.State === 0 && (i = "/", t && (t.IsAres3Enabled || t.IsAres2Disabled) && (i = "/ares3/"), n.location = i)
    };
    Ares.logOff = function (t) {
        !t || n.closed ? (sessionStorage && sessionStorage.clear(), n.localStorage ? (n.localStorage.removeItem("AresToken"), n.localStorage.removeItem("LogOnResult"), n.localStorage.removeItem("ExternalToken")) : ($.removeCookie("AresToken"), $.removeCookie("LogOnResult")), Ares.disableAutoLogOff(), n.location = Ares.logOffUrl) : Ares.autoLogOffDisabled || $.ajax({
            type: "Get",
            url: Ares.logOffUrlAjax
        })
    }
}(window)
